﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Others
{
    class Program
    {
        static void Main(string[] args)
        {
            Node root = new Node("root");
            Node sonA = new Node("sonA");
            Node sonB = new Node("sonB");
            Node grandSonA1 = new Node("grandSonA1");
            Node grandSonA2 = new Node("grandSonA2");
            Node grandSonB2 = new Node("grandSonB2");
            Node grandSonB1 = new Node("grandSonB1");

            sonA.Nodes.Add(grandSonA1);
            sonA.Nodes.Add(grandSonA2);
            sonB.Nodes.Add(grandSonB2);
            sonB.Nodes.Add(grandSonB1);

            root.Nodes.AddRange(new List<Node>() { sonA,sonB });

            Display(root, 0);

            Console.Read();
        }

        private static void Display(Node node, int indent)
        {
            Console.WriteLine(new String('-',indent)+node.Name);

            foreach (Node childNode in node.Nodes)
            {
                //if(childNode != null)
                    Display(childNode, indent + 2);
            }
        }
    }

    class Node
    {
        public Node(string name)
        {
            this.Name = name;
            this.Nodes = new List<Node>();
        }
        public string Name { get; set; }
        public List<Node> Nodes { get; set; }
    }
}
